/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Classes;

import java.util.Date;
import java.util.Objects;

/**
 * Représente une réservation
 * @author ZwoRmi
 */
class Reservation {
    private Personne _personneReservatrice;
    private Date _dateReservation;
    private int _nombreClients;
    /**
     * Constructors
     */
    public Reservation() {
        this.setPersonneReservatrice(new Personne());
    }

    public Reservation(Personne personneReservatrice, Date dateReservation, int nombreClients) throws Exception {
        this.setPersonneReservatrice(personneReservatrice);
        this.setDateReservation(dateReservation);
        this.setNombreClients(nombreClients);
    }
    /**
     * Getters and setters
     */
    public Personne getPersonneReservatrice() {
        return _personneReservatrice;
    }

    public void setPersonneReservatrice(Personne personneReservatrice) {
        this._personneReservatrice = personneReservatrice;
    }

    public Date getDateReservation() {
        return _dateReservation;
    }

    public void setDateReservation(Date dateReservation) throws Exception {
        Date currentDate= new Date();
        if (currentDate.after(dateReservation))
            throw new Exception("La date est passée");
        this._dateReservation = dateReservation;
    }

    public int getNombreClients() {
        return _nombreClients;
    }

    public void setNombreClients(int nombreClients) {
        this._nombreClients = nombreClients;
    }
    /**
     * Equals
     * @param obj
     * @return true si equals 
     */
    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Reservation other = (Reservation) obj;
        if (!Objects.equals(this._personneReservatrice, other._personneReservatrice)) {
            return false;
        }
        if (!Objects.equals(this._dateReservation, other._dateReservation)) {
            return false;
        }
        if (this._nombreClients != other._nombreClients) {
            return false;
        }
        return true;
    }
    
}
